package org.ns.tomdog.classloader;

import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

public class JarEnrtyWrapper {

    private JarFile jarFile;
    private JarEntry jarEntry;

    public JarEnrtyWrapper(JarFile jarFile, JarEntry jarEntry) {
        this.jarFile = jarFile;
        this.jarEntry = jarEntry;
    }

    public InputStream getInputStream() throws IOException {
        return jarFile.getInputStream(jarEntry);
    }
    public URL getURL() {
        try {
            String path = "jar:file:" + jarFile.getName() + "!/" + jarEntry.getName();
            return URI.create(path).toURL();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public JarFile getJarFile() {
        return jarFile;
    }

    public JarEntry getJarEntry() {
        return jarEntry;
    }

}
